<template>
  <div class="_wz_cent_main">
    <div class="_wz_deptConfiguration">
      <div style="max-width: 1000px;margin: auto;min-width:600px;">

        <Form :model="formData" label-position="right" :label-width="140">
          <FormItem label="运输企业">
            {{!!formData.deptName?formData.deptName:'--'}}
          </FormItem>
          <Row>
            <i-col span="12">
              <FormItem label="运输类型">
                {{!!formData.deptTransportName ? formData.deptTransportName : '--'}}
              </FormItem>
            </i-col>
            <i-col span="12">
              <FormItem label="剩余授权次数">
                {{!!formData.configAuthNumber ? formData.configAuthNumber : '0'}}条
              </FormItem>
            </i-col>
          </Row>

          <Divider>基本信息</Divider>
          <FormItem label="学员自动审核">
            <i-switch v-model.number="formData.configDriverVerifyFlag" :false-value="0" :true-value="1">
              <span slot="open">开</span>
              <span slot="close">关</span>
            </i-switch>
            <span style="margin: 0 30px;display: inline-block;width: calc(100% - 150px); vertical-align: top;">自动审核并同意从业人员入、离职申请</span>
          </FormItem>
          <FormItem label="培训自动授权">
            <i-switch v-model.number="formData.configDriverAuthFlag" :false-value="0" :true-value="1">
              <span slot="open">开</span>
              <span slot="close">关</span>
            </i-switch>
            <span style="margin: 0 30px;display: inline-block;width: calc(100% - 150px); vertical-align: top;">自动授权新入职从业人员培训权限</span>
          </FormItem>
<!--          <FormItem label="车辆数据同步">-->
<!--            <i-switch v-model.number="formData.configVehicleAsyncAutoFlag" :false-value="0" :true-value="1">-->
<!--              <span slot="open">开</span>-->
<!--              <span slot="close">关</span>-->
<!--            </i-switch>-->
<!--            <span style="margin: 0 30px;display: inline-block;width: calc(100% - 150px); vertical-align: top;">北斗安装新增车辆，自动同步到运营车辆。</span>-->
<!--          </FormItem>-->
          <FormItem label="人员合同签署">
            <i-switch v-model.number="formData.configDriverContractNeedFlag" :false-value="0" :true-value="1">
              <span slot="open">开</span>
              <span slot="close">关</span>
            </i-switch>
            <span style="margin: 0 30px;display: inline-block;width: calc(100% - 150px); vertical-align: top;">从业人员是否必须签署合同、承诺书、责任状、告知书</span>
          </FormItem>
          <Divider>数据订阅</Divider>
          <FormItem label="培训课程订阅">
            <i-switch v-model.number="formData.configTrainSubscriptionFlag" :false-value="0" :true-value="1">
              <span slot="open">开</span>
              <span slot="close">关</span>
            </i-switch>
            <span style="margin: 0 30px;display: inline-block;width: calc(100% - 150px); vertical-align: top;">每月自动接收平台推送的培训大纲课程</span>
          </FormItem>
          <FormItem label="考试测验订阅">
            <i-switch v-model.number="formData.configExamSubscriptionFlag" :false-value="0" :true-value="1">
              <span slot="open">开</span>
              <span slot="close">关</span>
            </i-switch>
            <span style="margin: 0 30px;display: inline-block;width: calc(100% - 150px); vertical-align: top;">每月自动接收平台推送的考试测验试卷</span>
          </FormItem>

          <Divider>数据初始化</Divider>
          <Button type="primary" @click="deptDataInit('safetyDrivingLogDrivingLogCheckInit','行车检查项')" style="margin: 0 0 10px 0;">行车检查项初始化</Button>
          <Button type="primary" @click="deptDataInit('safetyDrivingLogDrivingLogRemindInit','行车安全问询')" style="margin: 0 0 10px 0;">行车安全问询初始化</Button>




        </Form>
      </div>
    </div>
    <div class="demo-drawer-footer">
      <Button style="margin-right: 8px" @click="$emit('closeFun', false)">取消</Button>
      <Button type="primary" @click="addSubmit">保存</Button>
    </div>
    <Spin size="large" fix v-if="spinShow"></Spin>

  </div>
</template>
<script>
  export default {
    props: ['selectData'],//接收来自父组件的数据
    data() {
      return {
        spinShow:false,//本页加载
        formData: {
          configInsuranceRemindDay: 0,
          configInsuranceSmsSendDay: 0,
          configInsuranceSmsSend: 0,
          configAnnualInspectRemindDay: 0,
          configAnnualInspectSmsSendDay: 0,
          configAnnualInspectSmsSend: 0,
          configOperationCertificateRemindDay: 0,
          configOperationCertificateSmsSendDay: 0,
          configOperationCertificateSmsSend: 0,
          configMaintainRemindDay: 0,
          configMaintainSmsSendDay: 0,
          configMaintainSmsSend: 0,
          configTrailerVesselTaxRemindDay: 0,
          configTrailerVesselTaxSmsSendDay: 0,
          configTrailerVesselTaxSmsSend: 0,
          configTrainSubscriptionFlag: 0,
          configExamSubscriptionFlag: 0,
          configDriverVerifyFlag: 0,
          configDriverAuthFlag:0,
          configMaterialSubscriptionFlag:0,// 课件授权使用

        }
      }
    },
    beforeCreate() {//beforeCreate创建前状态

    },
    created() {//created创建完毕状态

    },
    beforeMount() {//beforeMount挂载前状态   DOM 元素然后塞入页面的过程

    },
    mounted() {//mounted 挂载结束状态
      let that = this;
      that.formData = JSON.parse(JSON.stringify(that.selectData));
    },
    methods: {//执行的方法
      addSubmit() {//新增修改提交
        let that = this;
        that.spinShow = true;
        that.axios.post(that.apiUrl.coreDeptConfigCoreDeptConfigSaveOrUpdate, that.formData).then(res => {
          that.spinShow = false;
          if (!!res) {
            that.$Message.success('保存成功');
            that.$emit("closeFun", true)
          }
        }).catch(err => {
          console.log('失败', err);
        })
      },
      //初始化数据
      deptDataInit(url,name){
        let that = this;
        that.$Modal.confirm({
          title: '初始化提醒',
          content: '确定要初始化'+name+'数据？初始化将会清除您原有的数据，请谨慎操作。',
          onOk: () => {
            that.$Spin.show();//显示加载
            that.axios.post(that.apiUrl[url],{deptUuid:that.formData.deptUuid,deptTransportCode:that.formData.deptTransportCode}).then(res => {
              that.$Spin.hide();//显示加载
              if (!!res) {
                that.$Message.success('初始化完成');
              }
            }).catch(err => {
              console.log('失败', err);
            })
          },
          onCancel: () => {
            //点击取消
          }
        });
      },
    },
    watch: {//监听

    },
    beforeUpdate() {//beforeUpdate 更新前状态

    },
    updated() {//updated 更新完成状态

    },
    beforeDestroy() {//beforeDestroy 销毁前状态

    },
    destroyed() {//destroyed 销毁完成状态

    }
  }
</script>
<style lang="less">
  ._wz_deptConfiguration {
    width: 100%;
    background: #fff;
  }

</style>
